import http from '../util/http.js';

export default {

    /*对商品的数据操作*/
    productGetOne:(id)=>{
        return http({url:'api/product/'+id,method:'get'});
    },
    productGetPage:async (current,size)=>{
        const val= await http({url:'api/product/page',method:'get',
            params:{current,size}
        });
        console.log("---------------");
        console.log(val);
        return val;
    },

    productDelete:(id)=>{
        http({
            url:"api/product/"+id,
            method:'delete'
        });
    },
    productEdit:(obj)=>{
        console.log(obj);
       return http({
            url:"api/product/",
            method:'PUT',
           data: obj,
           headers: {
               //定义将数据以json的形式传入后台(java)
               'Content-Type': 'application/json'
           }
        });
    },

    /*权限管理*/

    permissionAdd:(obj)=>{
        return http({
            url:"api/permission/",
            method:'POST',
            data: obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    permissionDelete:(id)=>{
        return http({
            url:"api/permission/"+id,
            method:'DELETE'
        });
    },
    permissionEdit:(obj)=>{
        return http({
            url:"api/permission/",
            method:'PUT',
            data: obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    permissionPage:(current,size)=>{
        return http({
            url:'api/permission/page',
            params:{current,size},
            method:"GET"
        });
    },
    rolePage:(current,size)=>{
        return http({
            url:'api/role/page',
            params:{current,size},
            method:"GET"
        });
    },
    permissionList:()=>{
        return http({
            url:'api/permission/list',
            method:"GET"
        });
    },
    roleByID:(id)=>{
        return http({url:"api/role/"+id});
    },
    assignPermisssion:(obj)=>{
        return http({
            url:"api/role/assign",
            method:"PUT",
            data:obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    }



}